package learn;

import com.sun.javafx.print.Units;

public class Test {
	static int[] units = new int[400000];
	static int steps = 0;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		for (int i = 0; i < 399999; i++) {
			units[i] = (int) Math.floor(Math.random() * 10);
		}
		while (true) {
			int virotas = 0;
			for (int item : units) {
				virotas = virotas + item;
			}
			if (virotas < 5) {
				System.out.println("step used:" + steps);
				System.out.println("virotas:" + virotas);
				System.out.println("time used:" + (System.currentTimeMillis() - start) + "ms");
				break;
			} else {
				int targetItem=0;
				while(true){
					targetItem = (int) Math.floor(Math.random() * 400000);
					if(units[targetItem] > 0){
						units[targetItem] = units[targetItem] - 1;
						steps++;
						break;
					}
				}
			}

		}
	}
}
